#include <iostream>
using namespace std;

class examinfo{
private:
    string name;
    enum {Grade, Pass, Percent} mode;
    union {
        char grade;
        bool pass;
        double percent;
    };
public:
    examinfo(string name, char grade) : name(name), mode(Grade), grade(grade) {}
    examinfo(string name, bool pass) : name(name), mode(Pass), pass(pass) {}
    examinfo(string name, double percent) : name(name), mode(Percent), percent(percent) {}
    void show();
    ~examinfo();
};


void examinfo::show(){
    cout << name << ": ";
    switch (mode) {
    case Grade:
        cout  << grade << endl;
        break;
    case Pass:
        cout  << (pass ? "pass" : "fail") << endl;
        break;
    case Percent:
        cout << percent << endl;
        break;
    default:
        break;
    }
}
examinfo::~examinfo(){
    cout << "distory the ~examinfo()" << endl;
}

int main()
{
    examinfo e1("english", 'A');
    examinfo e2("calcu", true);
    examinfo e3("cpp", 90.5);
    e1.show();
    e2.show();
    e3.show();
    return 0;
}